home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows News 2010 Summer - Disc 1
/
WN_Ete2010_CD1.iso
/
Onglet5
/
Weezo
/
Weezo setup.exe
/
{code_appDir}
/
www
/
res
/
administration
/
config
/
wallpaper.php
< prev
next >
Wrap
PHP Script
|
2010-05-19
|
8KB
|
217 lines
<?php
/**
* Accounts remote configuration
*
* PHP version 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
*
* @category NA
* @package NA
* @author Nicolas Bruley / Peer 2 World <contact@weezo.net>
* @copyright 2005-2009 Nicolas Bruley / Peer 2 World
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id:$
* @link http://www.weezo.net
* @since File available since Release 2.0.0
*/
if(cfUGetVar('accountType')!='singleUser') die('unauthorized access');
define('PREVIEW_WIDTH',70);
define('PREVIEW_HEIGHT',60);
require_once(INCLUDE_DIR.'outputFunctions.php');
require_once(INCLUDE_DIR.'applicationConfigFunctions.php');
$position=(cfUGetVar('wallpaperPosition'))?cfUGetVar('wallpaperPosition'):'centered';
// Initialize data
outControlSetData(array('wallpaperPosition'=>$position));
/*
***************************************************************************************************************************
* Process POST commands
***************************************************************************************************************************
*/
$wallpaperPositionControl=outControl('wallpaperPosition',
dataList,'centered',
array('stretched','centered','tiled'),
array(
array(outImage(outIcon('wpStretched'),false,false,'vertical-align:bottom;margin-right:0.2em'),'stretched',cfCaption('configWPStretched')),
array(outImage(outIcon('wpCentered'),false,false,'vertical-align:bottom;margin-right:0.2em'),'centered',cfCaption('configWPCentered')),
array(outImage(outIcon('wpTiled'),false,false,'vertical-align:bottom;margin-right:0.2em'),'tiled',cfCaption('configWPTiled'))
)
);
if(cfIsAsync()){
cfAsyncHeader();
// Wallpaper position
if(outControlGetData($options) && !isset($_POST['setBackground'])) {
foreach ($options as $k=>$v) cfUSetVar($k,$v);
$modified=true;
}
// Wallpaper image
if(isset($_POST['setWP']) && ($_POST['setWP']=='no' || $_POST['setWP']=='theme' || file_exists($cfn=cfJoinPathFile(cfAppDocRoot().'/gfx/wallpapers/',$_POST['setWP'])))){
if($_POST['setWP']!=cfUGetVar('wallpaper')){
if($_POST['setWP']=='no' || $_POST['setWP']=='theme') $cfn=$_POST['setWP'];
cfUSetVar('wallpaper',basename($cfn));
$options['wallpaper']=basename($cfn);
$modified=true;
}
}
if(isset($modified)){
$wp=cfUGetVar('wallpaper');
}
// Background color
if(isset($_POST['setBackground'])){
$_POST['setBackground']=str_replace('#','sharp',str_replace(chr(32),'',$_POST['setBackground']));
if(preg_match('/^sharp[0-9a-fA-f]{6}$/', $_POST['setBackground'])||preg_match('/^rgb\([0-9]{1,3},[0-9]{1,3},[0-9]{1,3}\)$/i', $_POST['setBackground'])){
$_POST['setBackground']=str_replace('sharp','#',$_POST['setBackground']);
if(cfUGetVar('desktopColor')!=$_POST['setBackground']) $modified=true;
cfUSetVar('desktopColor',$_POST['setBackground']);
$options['desktopColor']=$_POST['setBackground'];
}
}
// Commit to user configuration
if(isset($modified)){
require_once(INCLUDE_DIR.'resourceConfigFunctions.php');
rcUserSaveValues($options);
}
//echo cfAsyncXMLJSaction('setColPickVisibility()');
echo $outControlAsyncResponse;
die (cfAsyncFooter());
}
$wp=cfUGetVar('wallpaper');
cfInsertHEAD(false);
?>
<script type="text/javascript">
var selected="<?php echo $wp?>";
var position="<?php echo $position?>";
var colPickOverCB,colPickClickCB;
function colPickMO(e){
var c=(e&&e.target)?e.target.style.backgroundColor:((event&&event.srcElement)?event.srcElement.style.backgroundColor:false);
if(c) cpOverCB(c)
}
function colPickC(e){
var c=(e&&e.target)?e.target.style.backgroundColor:((event&&event.srcElement)?event.srcElement.style.backgroundColor:false);
if(c) cpClickCB(c)
}
function colPick(n,overCB,clickCB){
cpOverCB=overCB;cpClickCB=clickCB;
var nb=0,r,g,b;
var out='<table class="cp">';
for(g=0;g<15;g+=3) for(r=0;r<=15;r+=3) for(b=0;b<=15;b+=3){
nb++;
if((nb%18)==1) {
gr=Math.floor(256*(nb-1)/162);
out+='<tr><td style="background:rgb('+(gr)+','+(gr)+','+(gr)+')"> </td><td> </td>\n';;
}
out+='<td style="background:rgb('+(r*16)+','+(g*16)+','+(b*16)+')"> </td>\n';
if((nb%18)==0) out+='</tr>';
}
n.innerHTML=out+'</table>';
if(overCB) n.onmouseover=colPickMO;
if(clickCB) n.onclick=colPickC;
}
function cpmo(col){}
// Color changed
function cpc(col){
setBackgroundColor(col);
sendData('setBackground='+col.replace(/#/,'sharp'))
}
// Wallpaper changed
function setWP(node,name){
if(selected==name) return;
selected=name;
var n=dgi('cont').firstChild,src=(name=='theme'||name=='no')?name:'/gfx/wallpapers/'+name;
while(n){n.className='ts';n=n.nextSibling}
node.className="tss";
setColPickVisibility();
setWallpaper(src,position);
sendData('setWP='+name);
}
// Wallpaper position changed
function asUpdtFunction(k,v){
if(k!='wallpaperPosition') return;
position=v;
var src=(selected=='theme'||selected=='no')?selected:'/gfx/wallpapers/'+selected;
setWallpaper(src,position);
}
function unsel(n){if(n.className.substr(0,3)=='tss') n.className='tss'; else n.className='ts';}
function sel(n){if(n.className.substr(0,3)=='tss') n.className='tss h'; else n.className='ts h';}
function setWallpaper(src,position){if(parent && parent.setWallpaper) parent.setWallpaper(src,position);}
function setBackgroundColor(c){if(parent && parent.setBackgroundColor) parent.setBackgroundColor(c);}
function setColPickVisibility(){
if(selected=='no' || (dgn("asUpdtwallpaperPosition",1).checked && selected!='theme') && selected.substr(0,1)!='-') {
dgi('cpF').style.display='';
}
else dgi('cpF').style.display='none';
dgi("wallpaperPosition").style.visibility=((dgi('noWP').className.substr(0,3)=='tss'||dgi('theme').className.substr(0,3)=='tss')?"hidden":"")
return true;
}
function init(){
colPick(dgi("cp"),null,cpc);
setColPickVisibility();
}
</script>
<style type="text/css">
.cp{table-layout:fixed;cursor:pointer}
.cp td {width:10px;height:10px;margin:1}
.tss{background:#CCE;border:1px solid #CCC;padding:9px;margin:3px;vertical-align:middle;text-align:center;color:black}
.ts{background:white;border:1px solid #CCC;padding:9px;margin:3px;vertical-align:middle;text-align:center;color:black}
.tstxt{background:white;border:1px solid #DDD}
.h{background:#DDF}
</style>
</head>
<body onload="init()">
<center id="wallpaperPosition" style="<?php echo (($wp=='no'||$wp=='theme')?'visibility:hidden':'');?>">
<?php
echo $wallpaperPositionControl;
?>
</center>
<div id="cont" style="">
<?php
// No wallpaper
echo '<fieldset id="noWP" class="'.(($wp=='no')?'tss':'ts').'" style="display:inline" onmouseover="sel(this)" onmouseout="unsel(this)" onclick="setWP(this,\'no\')">';
echo '<div class="tstxt smallFont" style="width:'.PREVIEW_WIDTH.';height:'.PREVIEW_HEIGHT.'"><div style="padding-top:25%">'.cfCaption('configWPNo').'</div></div>';
echo '</fieldset>';
// Theme default
echo '<fieldset id="theme" class="'.(($wp=='theme')?'tss':'ts').'" style="display:inline" onmouseover="sel(this)" onmouseout="unsel(this)" onclick="setWP(this,\'theme\')">';
echo '<div class="tstxt" style="width:'.PREVIEW_WIDTH.';height:'.PREVIEW_HEIGHT.'"><div style="padding-top:35%">'.cfCaption('genTheme').'</div></div>';
echo '</fieldset>';
// Wallpapers
foreach (glob(cfAppDocRoot().'/gfx/wallpapers/*.{gif,jpg,jpeg,png}',GLOB_BRACE) as $cfn) {
if(cfGetBrowser()=='ie') echo '<span class="'.((basename($cfn)===$wp)?'tss':'ts').'" style="display:inline-block" onmouseover="sel(this)" onmouseout="unsel(this)" onclick="setWP(this,\''.basename($cfn).'\')"><img src="'.cfExtGFX('/gfx/wallpapers/'.basename($cfn),PREVIEW_WIDTH,PREVIEW_HEIGHT).'" style="visibility:hidden" onload="fade(this)"></span>';
else echo '<img class="'.((basename($cfn)===$wp)?'tss':'ts').'" src="'.cfExtGFX('/gfx/wallpapers/'.basename($cfn),PREVIEW_WIDTH,PREVIEW_HEIGHT).'" style="visibility:hidden" onmouseover="sel(this)" onmouseout="unsel(this)" onclick="setWP(this,\''.basename($cfn).'\')" onload="fade(this)">';
}
?>
</div>
<div class="frame1" id="cpF">
<div class="frame1Header"><?php echo cfCaption('backgroundColor');?></div>
<center id="cp"></center>
</div>
</body>